package day04;

import java.util.Scanner;

public class HomeWork {
    public static void main(String[] args) {
        //猜数字游戏
        /*
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入您要猜的数字：");
        int guess = sc.nextInt();  //输入猜的数字
        int num = (int)(Math.random()*1000+1);  //生成的随机数字
        while (guess != num){
            if(guess > num){
                System.out.println("猜大了");
            }else if(guess < num){
                System.out.println("猜小了");
            }
            System.out.println("请您重新猜：");
            guess = sc.nextInt();
        }
        System.out.println("恭喜您，猜对了");
        */

       /*
       //while死循环
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入您要猜的数字");
        int num = (int)(Math.random()*1000+1);
        while (true){
            int guess = sc.nextInt();
            if(guess > num){
                System.out.println("猜大了");
            }else if(guess < num){
                System.out.println("猜小了");
            }else {
                System.out.println("恭喜您，猜对了");
                break;
            }
        }
        */

     /*
       //猜数字游戏
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入您要猜的数字：");
        int guess = sc.nextInt();  //输入猜的数字
        int num = (int)(Math.random()*1000+1);  //生成的随机数字
        while (guess !=  num ){
            if(guess > num){
                System.out.println("猜大了");
            }else if(guess < num){
                System.out.println("猜小了");
            }
            System.out.println("请您重新猜：");
            guess =sc.nextInt();
        }
        System.out.println("恭喜您，猜对了");
        */

       /*
        //while 死循环
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入您要猜的数字：");
        int guess = sc.nextInt(); //输入的数字
        while (true ){
            int num = (int)(Math.random()*1000+1);
            if(guess > num){
                System.out.println("猜大了");
            }else if(guess > num){
                System.out.println("猜小了");
            }else {
                System.out.println("恭喜您，猜对了");
                break;
            }
        }
        */

        /*
        //for循环：
        //输出5次"行动是成功的阶梯"
        for (int num = 0; num < 5; num++) {
            System.out.println("行动是成功的阶梯");
        }
        //输出9的乘法表(1到9、1/3/5/7/9)
        for (int num = 1; num <= 9; num++) {
            System.out.println(num+"*9="+num*9);
        }
        for (int num = 1; num <= 9; num += 2) {
            System.out.println(num+"*9="+num*9);
        }
        //累加1到100的和
        int sum = 0;  //定义一个求和变量
        for (int num = 1; num <= 100; num++) {
            sum += num;
        }
        System.out.println(sum);
        */

       /*
       //for循环：
        //输出5次"行动是成功的阶梯"
        for (int num = 0; num < 5; num++) {
            System.out.println("行动是成功的阶梯");
        }
        //输出9的乘法表(1到9、1/3/5/7/9)
        for (int num = 1; num <= 9; num++) {
            System.out.println(num+"*9="+num*9);
        }
        for (int num = 1; num <= 9; num += 2) {
            System.out.println(num+"*9="+num*9);
        }
        //累加1到100的和
        int sum = 0;
        for (int num = 1; num <= 100; num++) {
            sum += num;
        }
        System.out.println(sum);
        */

        /*//MultiTable九九乘法表  要求：输出九九乘法表
        for (int num = 1; num <= 9; num++) {

            for (int i = 1; i <= num; i++) {
                System.out.print(i+"*"+num+"="+i*num+" \t");  //
            }
            System.out.println();
        }

        for (int num = 1; num <= 9; num++) {

            for (int i = 1; i <= num; i++) {
                System.out.print(i + "*" + num + "=" + i*num + "\t");
            }
            System.out.println();
        }*/


       /*
        // 数组小代码练习：声明、初始化
        int [] arr = {1,2,3};
        int [] arr1 = new int [] {1,2,3};
        int [] arr2;
        arr2 = new int[]{1,2,3};
        int [] arr3 = new int[3];
        System.out.println(arr.length);
        System.out.println(arr1.length);
        System.out.println(arr2.length);
        System.out.println(arr3.length);
        */

    }
}
